package com.util;

import java.util.List;

public class Page {
    private int pageNum; //当前页面数
    private int pageSize = 10; //每页条数
    private int total; //总记录数
    private int pages; //总页数
    private int offset; //mysql中的起始偏移量
    private int prePage; //上一页
    private int nextPage; //下一页
    private boolean firstPage; //是否为首页
    private List data; //当前页数据
    public int getPageNum() {
        return pageNum;
    }
    public void setPageNum(int pageNum) {
        this.pageNum = pageNum;
    }
    public int getPageSize() {
        return pageSize;
    }
    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }
    public int getTotal() {
        return total;
    }
    public void setTotal(int total) {
        this.total = total;
    }
    public int getPages() {
        return getTotal()%getPageSize()==0 ? getTotal()/getPageSize() : getTotal()/getPageSize()+1;
    }
    public void setPages(int pages) {
        this.pages = pages;
    }
    public int getOffset() {
        return (getPageNum()-1)*getPageSize();
    }
    public void setOffset(int offset) {
        this.offset = offset;
    }
    public int getPrePage() {
        return Math.max(getPageNum() - 1, 1);
    }
    public void setPrePage(int prePage) {
        this.prePage = prePage;
    }
    public int getNextPage() {
        return Math.min(getPageNum() + 1, getPages());
    }
    public void setNextPage(int nextPage) {
        this.nextPage = nextPage;
    }
    public boolean isFirstPage() {
        return getPageNum()==1;
    }
    public void setFirstPage(boolean firstPage) {
        this.firstPage = firstPage;
    }
    public boolean isLastPage() {
        return getPageNum()==getPages();
    }
    public void setLastPage(boolean lastPage) {
        //是否为末页
    }
    public List getData() {
        return data;
    }
    public void setData(List data) {
        this.data = data;
    }

}
